﻿Imports System.Linq
Imports System.Text
Imports System.Xml.Serialization
Imports System.ComponentModel

<Serializable()> _
    Public Class AwayMessage
    Implements INotifyPropertyChanged

    Private _sender As String
    Private _message As String
    Private _isPrivate As Boolean
    Private _when As DateTime

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

    Public Property Sender() As String
        Get
            Return _sender
        End Get
        Set(ByVal value As String)
            _sender = value
            PropChanged("Sender")
        End Set
    End Property

    Public Property Message() As String
        Get
            Return _message
        End Get
        Set(ByVal value As String)
            _message = value
            PropChanged("Message")
        End Set
    End Property

    Public Property IsPrivate() As Boolean
        Get
            Return _isPrivate
        End Get
        Set(ByVal value As Boolean)
            _isPrivate = value
            PropChanged("IsPrivate")
        End Set
    End Property

    Public Property [When]() As DateTime
        Get
            Return _when
        End Get
        Set(ByVal value As DateTime)
            _when = value
            PropChanged("When")
        End Set
    End Property

    Public Overloads Overrides Function ToString() As String
        Return String.Format("[{0:t}] {1} by {2}", _when, _message, _sender)
    End Function

#Region "INotifyPropertyChanged Members"

    Private Sub PropChanged(ByVal prop As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(prop))
    End Sub
#End Region
End Class
